﻿Imports System
Imports System.IO
Imports System.Text

Public Class FileLastAccessTime
    Public Shared Sub Main()
        'Try
        Dim _diretorio As String = "C:\Projetos\ArtNoi\Storage\ExperimentoWatchFile_APAGAR\"
        Dim path As String = _diretorio & "ArquivoTeste.txt"
        Dim _arquivos As String() = Directory.GetFiles(_diretorio)

        If Directory.Exists(_diretorio) = False Then
            Directory.CreateDirectory(_diretorio)
        End If

        If File.Exists(path) = False Then
            File.Create(path)
        End If
        'File.SetLastAccessTime(path, New DateTime(1985, 5, 4))

        ' Get the creation time of a well-known directory.
        'Dim dt As DateTime = File.GetLastAccessTime(path)

        'Console.WriteLine("The last access time for this file was {0}.", dt)

        ' Update the last access time.
        'File.SetLastAccessTime(path, DateTime.Now)

        Dim i As Integer = 1
        While True
            Console.Clear()
            Console.WriteLine("{0}s", i)
            For Each _arquivo In _arquivos
                Console.WriteLine(_arquivo)
                Console.WriteLine("     CreationTime   {0}.", File.GetCreationTime(_arquivo))
                Console.WriteLine("     LastWriteTime  {0}.", File.GetLastWriteTime(_arquivo))
                Console.WriteLine("     LastAccessTime {0}.", File.GetLastAccessTime(_arquivo))
            Next
            i += 1
            Threading.Thread.Sleep(1000)
        End While


        'Catch e As Exception
        'Console.WriteLine("The process failed: {0}", e.ToString())
        'End Try
    End Sub
End Class

